const { addGoods, getGoods, deleteGoodsById, updateGoodsById, searchGoods, getGoodsByPage } = require('../dao/goodsDao.js')
module.exports.addGoods = async newGoods => {
    const result = await addGoods(newGoods);
    if (result._id) {
        return true;
    }
    return false;
}
module.exports.getGoods = async _id => {
    const result = await getGoods(_id);
    if (result.length > 0) {
        return result;
    }
    return false;
}
module.exports.deleteGoodsById = async GoodsId => {
    const result = await deleteGoodsById(GoodsId);
    if (result.ok === 1) {
        return true;
    }
    return false;
}

module.exports.updateGoodsById = async Goods => {
    const result = await updateGoodsById(Goods);
    if (result.ok === 1) {
        return true;
    }
    return false;
}
module.exports.searchGoods = async Goods => {
    const result = await searchGoods(Goods);
    if (result.length > 0) {
        return result;
    }
    return false;
}
module.exports.getGoodsByPage = async page => {
  const data=  await getGoodsByPage(page);
    return data
}